package ict.kth.se.model.repository;

import ict.kth.se.exceptions.EntityAlreadyExistsInDBException;
import ict.kth.se.exceptions.EntityDoesntExistInDBException;
import ict.kth.se.model.Availability;
import ict.kth.se.model.CompetenceProfile;

import java.sql.SQLException;
import java.util.List;

public interface AvailabilityRepository {

	/**
	 * Get Availability by id
	 * @param id Id of availability
	 * @return Found availability
	 */
	public Availability getAvailabilityById(Long id) throws SQLException;
	
	/**
	 * Get Availabilities by person's id
	 * @param id Id of person to get availabilities
	 * @return Found availabilities
	 */
	public List<Availability> getAvailabilitiesByPersonId(Long personId) throws SQLException;
	
	/**
	 * Get all availabilities
	 * @return Found availabilities
	 */
	public List<Availability> getAllAvailabilities() throws SQLException;
	
	/**
	 * This method removes one availability from database (by it's ID)
	 * @param availability The availability to be removed
	 * @throws EntityDoesntExistInDBException If availability doesn't exist in database
	 * @throws SQLException
	 */
	public void removeAvailability(Availability availability) throws EntityDoesntExistInDBException, SQLException;
	
	/**
	 * This method removes one availability from database by person's ID
	 * @param personId ID of the person to delete availability for
	 * @throws EntityDoesntExistInDBException If availability doesn't exist in database
	 * @throws SQLException
	 */
	public void removeAvailabilitiesForPerson(Long personId) throws EntityDoesntExistInDBException, SQLException;
	
	/**
	 * This method adds an availability in DB
	 * @param availability Availability to be added
	 * @param personId Id of person that availability should be connected to
	 * @return Newly created availability
	 * @throws EntityAlreadyExistsInDBException If such availability already exists in DB (by name)
	 * @throws SQLException
	 */
	public Availability createAvailability(Availability availability, Long personId) throws EntityAlreadyExistsInDBException, SQLException;
	
	/**
	 * This method updates an availability in DB
	 * @param availability Availability to be updated
	 * @param personId Id of person that availability should be connected to
	 * @throws EntityDoesntExistInDBException If such availability doesn't exist in DB (by id)
	 * @throws SQLException
	 */
	public void updateAvailability(Availability availability, Long personId) throws EntityDoesntExistInDBException, SQLException;
}
